package com.zzw.hj33;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @Project: hw_java
 * @Description: 整数与ip地址间的转换
 * @Author: zzw
 */

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        while ((str = br.readLine()) != null) {
            String[] ip = str.split("\\.");
            long num = Long.parseLong(br.readLine());
            //转10进制
            System.out.println(Long.parseLong(ip[0]) << 24 | Long.parseLong(ip[1]) << 16 |
                    Long.parseLong(ip[2]) << 8 | Long.parseLong(ip[3]));
            //转ip地址
            String sb = ((num >> 24) & 255) + "." + ((num >> 16) & 255) + "." +
                    ((num >> 8) & 255) + "." + (num & 255);
            System.out.println(sb);
        }
    }
}